Creating a Bot/Python
Twitter Bots Visit this page! Templates Facebook Bots If you don't know the basics of using facebook-sdk, refer to this guide: How to make a facebook bot (basics) If you know python, and are okay with reading a bit of api docs, you may skip the basics. Also you would need: *Python 3.x *IDE (preferably VS Code/Sublime Text/Atom) *Loads of free time *VPS/ Host (Anything is fine here, even your PC is okay if you can keep it on 24/7, otherwise if you can use Amazon's AWS, Google Cloud, Microsoft Azure, etc) Here, i will be walking you through the process of writing the code, getting the access token, and just a sneak peak of scheduling your bot! Now time for some coding! Lets say you want to make a Lottery Ticket Bot (classic example). Firstly we would need to generate lottery tickets, which are essentially random. So lets rev up our text editors. In my case, I'm using Sublime Text 3. If you are using Sublime Text as well, it should look like this to you (considering you're in a folder) Great! Now lets do some coding. Considering python is basically just spicy English, it shouldn't be too difficult. So after writing literally 3 lines of code, we come up with this But this doesn't quite look like a lottery ticket number, does it? That fix should be easy, just a little for loop to insert a space within out number... And overall, tweaking the code a bit to make it look better, Basically i put everything into functions to make the code a bit more organized. This gives us the output the first output is the originally generated number and the second is the better looking version That means, we are now ready to make our bot live on Facebook! I am using my test page for this purpose, but it should be more or less the same for you people. After creating the page, head over to this site and get an access token for your bot! I'm not going to dive deep on how to generate the token as Paintmin, the site owner and our Lord at The Bot Appreciation Society has a pretty detailed description of that on his site. Now, store the token in your program in a variable with whatever name you want. After that we need a function that can post the Ticket on Facebook. Here's the code for the function: If youre wondering why put_photo and not '''put_object, '''thats because Facebook blocks text posts from time to time and marks it as spam. So, we attach a 400*1 white image to make it seem like a regular text post. You can download the image from here Overall, this is how it looks: Now its time to run it... and viola, It worked! Lets see if it actually posted anything or not. Yes it did! Now back to work... We have to make our bot post the ticket to our page. For that, we make a minor adjustment to the end of the code: Lets see if it worked... Yay! It worked perfectly! Now we need the bot to do this every 30 minutes lets say, For that, we can use this god sent module called schedule. (use pip install schedule to get the module) After that lets import schedule & time and shove everything in the main function to another function called job. Now All you need to do is let the code run, and it will keep posting lottery numbers. Of course, posting lottery numbers wont make a bot fun. Try coming up with bot ideas, and integrate them with the code we just wrote. I'm positive you can code a brilliant bot as well! -Boidushya (Admin of pages like Every Tom and Jerry Frame in Order, Blessed Bot 6009, Deep Fry Bot 6969, etc...)